//
//  VC1.m
//  MyBlock
//
//  Created by yuanjiang on 2016/11/24.
//  Copyright © 2016年 YuanJiang. All rights reserved.
//

#import "VC1.h"

@interface VC1 ()

@end

@implementation VC1

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    //创建一个输入框
    UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(20, 200, [UIScreen mainScreen].bounds.size.width-40, 40)];
    tf.placeholder = @"输入汉字可改变上个界面button的title";
    tf.tag = 110;
    tf.layer.borderWidth = 2;
    tf.layer.borderColor = [UIColor redColor].CGColor;
    [self.view addSubview:tf];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:@"点我返回" forState:UIControlStateNormal];
    [btn setFrame:CGRectMake(100, 500, 100, 100)];
    [btn setBackgroundColor:[UIColor blueColor]];
    [btn addTarget:self action:@selector(clickBack:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
}

- (void)clickBack:(UIButton *)sender
{
    UITextField *tf = (UITextField *)[self.view viewWithTag:110];
    if (self.passvalueblock) {
        self.passvalueblock(tf.text);
    }
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
